"""
URL configuration for tracer project.

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/5.1/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  path('', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  path('', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.urls import include, path
    2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, re_path ,include
from app01.views import login, project, index, manage, wiki, file

urlpatterns = [
    # path('admin/', admin.site.urls),

    # 注册 和 登录、忘记密码
    path('login/', login.login),
    path('register/', login.register),
    path('forgot/password/',login.forget_password),
    # """ 验证和密码 """
    # 研究: 如何处理中间件的屏蔽问题?
    # re_path(r'^send_email_code/$', login.send_email_code,name='send_email_code'),
    path('send/email_code/forget/', login.send_email_code_forget),
    path('send/email_code/register/', login.send_email_code_register),
    path('image/code/', login.image_code),

    path('logout/', login.logout),

    # 主页
    path('index/', index.index),



    # 项目列表
    path('project/list/', project.project_list),
    # path('project/star/<str:project_type>/<int:project_id>/', index.project_star, name='project_star')
    re_path(r'^project/star/(?P<project_type>\w+)/(?P<project_id>\d+)/$',
            project.project_star,
            name='project_star'),
    re_path(r'^project/unstar/(?P<project_type>\w+)/(?P<project_id>\d+)/$',
            project.project_unstar,
            name='project_unstar'),


    re_path(r'^manage/(?P<project_id>\d+)/', include([
        re_path(r'^$', manage.dashboard, name='dashboard'),  
        re_path(r'^dashboard/$', manage.dashboard, name='dashboard'),
        re_path(r'^issues/$', manage.issues, name='issues'),
        re_path(r'^statistics/$', manage.statistics, name='statistics'),  

        re_path(r'^file/$', file.file, name='file'),
        re_path(r'^file/delete/$', file.file_delete, name='file_delete'),
        re_path(r'^cos/credentials/$', file.cos_credentials, name='cos_credentials'),
        re_path(r'^file/post/$', file.file_post, name='file_post'),

        re_path(r'^wiki/', include([
            re_path(r'^$', wiki.wiki, name='wiki'),
            re_path(r'^add/$', wiki.wiki_add, name='wiki_add'),
            re_path(r'^catalog/$', wiki.wiki_catalog, name='wiki_catalog'),
            re_path(r'^delete/(?P<wiki_id>\d+)/$', wiki.wiki_delete, name='wiki_delete'), 
            re_path(r'^edit/(?P<wiki_id>\d+)/$', wiki.wiki_edit, name='wiki_edit'), 
            re_path(r'^upload/$', wiki.wiki_upload, name='wiki_upload'), 
        ])),
        re_path(r'^setting/$', manage.setting, name='setting'),
    ])),


]
